import 'package:shared_preferences/shared_preferences.dart';

class StoreKeyList {
  static const String loginToken = "login_token";
  static const String city = "city";
}

class Store {
  final SharedPreferences? _store;

  // static String _String = String.token;

  static Future<Store> getInstance() async {
    SharedPreferences? sharedPreferences = await SharedPreferences.getInstance();
    return Store._internal(sharedPreferences);
  }

  Store._internal(SharedPreferences this._store);

  getString(String keys) async {
    if (_store == null) {
      return '获取string失败';
    } else {
      return _store!.getString(keys);
    }
  }

  setString(String keys, String value) async {
    if (_store == null) {
      return '设置string失败';
    } else {
      return _store!.setString(keys, value);
    }
  }

  getStringList(String keys) async {
    if (_store == null) {
      return '获取string list失败';
    } else {
      return _store!.getStringList(keys);
    }
  }

  setStringList(String keys, List<String> value) async {
    if (_store == null) {
      return '设置string list失败';
    } else {
      return _store!.setStringList(keys, value);
    }
  }
}
